﻿using AgencyManagerSystem.Common;
using System;
using System.Collections.Generic;
using System.Text;

namespace AgencyManagerSystem.DataFetcher
{
    public class Conditions
    {
        public string ConditionArgs { get; set; }
        public int Position { get; set; }
        public int Size { get; set; }
    }
    public class Condition
    {
        //尝试把key-value字符串转换成Condition类型
        public static Condition[] MakeCondition(params string[] keyValueStr)
        {
            try
            {
                List<Condition> conditions = new List<Condition>();
                foreach(string keyValueNode in keyValueStr)
                {
                    string[] keyVal = keyValueNode.Split(new char[] { '='});
                    conditions.Add(new Condition() { Key = keyVal[0], Value = keyVal[1], Op = "=" });
                }
                return conditions.ToArray();
            }
            catch(Exception ex)
            {
                LogHelper.Err(typeof(Condition).ToString(),ex.Message);
                return new Condition[] { new Condition() { Key = "Auto", Value = "-1", Op = "=" } };
            }
        }

        public string Key { get; set; }
        public object Value { get; set; }
        public string Op { get; set; }
    }
}
